/**
 * Created by tanbingqin on 2019/12/2.
 */
import React from 'react'
import { connect } from 'react-redux';
import { messages } from 'share/common';
import { Form, Input, InputNumber, Button, Select, Switch, Icon, Radio, message, Row, Col} from 'antd';
import SelectEmployeeGroup from 'components/template/select-employee-group'
import travelPolicyService from 'containers/expense-reimbursement-control/expense-standard/travel-policy/travel-policy.service'
import ValueRule from 'containers/travel-standard/value-rule'
import Chooser from 'components/chooser'
import chooserData from 'share/chooserData'
import Searcher from 'components/searcher'
import Priority from 'components/template/priority'
import Permission from 'components/template/permission'
import 'styles/travel-standard/travel-standard.scss'
import policyService from "containers/travel-standard/travel-standard.service"
import errorMessage from 'share/errorMessage'
import Amount from "containers/travel-standard/comp/amount"
import AllocationForm from 'containers/travel-standard/comp/form'
import BaseService from 'share/base.service';

const FormItem = Form.Item;
const Option = Select.Option;
const RadioGroup = Radio.Group;

class NewRule extends React.Component{
  constructor(props){
    super(props);
    this.state = {
      loading: false,
      disabled: false, //只查看权限
      setOfBooksId: '', //所属组织上的帐套
      permissionTop: 'SET_OF_BOOK', //SET_OF_BOOK帐套级权限 COMPANY 公司级权限
      priorityValue: {}, //所属组织，启用公司控件value
      priorityRangeValue: {}, //所属组织控件的rangeValue，包含整个对象信息
      hasProcessDefaultPriority: false, //是否处理过所属组织的默认值
      userScopeValue: {
        range: 'ALL',
        value: []
      }, //适用人员控件value
      formScopeValue: {
        range: 'ALL',
        value: []
      }, //适用表单控件value
      valueRuleList: [], //值列表条件规则
      classOptions: [], //飞机舱等，火车座席
      cityOptions: [
        {levelName: messages('request-1.key735')/*通用*/, levelOID: '000000000'},
        {levelName: messages('request-1.key512')/*其他*/, levelOID: '111111111'}
      ],
      isShowValueRule: true, //是否展示值列表条件配置
      customEnumerationDTOs: [] //value-rule的初始化数据 ps：value-rule是靠重新加载组件来初始化数据，不在componentWillReceiveProps接收新数据
    }
  }

  componentWillMount() {
    const { currentMenuPermission, record, sceneId } = this.props;
    this.initPriority(currentMenuPermission);
    this.initClassOptions();
    if (record) {
      this.setState({
        disabled: !!record.readOnly,
        customEnumerationDTOs: JSON.parse(JSON.stringify(record.customEnumerationDTOs || []))
      });
      this.initPriorityValue();
      this.initUserScope();
      this.initFormScope();
    } else {
      if (sceneId) {
        //新建用餐的差标要初始化从用餐类型上带入的组织权限
        this.initPriorityInScene();
      }
    }
  }

  componentWillReceiveProps(nextProps) {}

  initPriorityInScene = () => {
    const { scene } = this.props;
    let setOfBooksId = '';
    let priorityValue = {
      levelCode: scene.levelCode,
      levelOrgId: scene.levelOrgId,
      levelOrgName: scene.levelName
    };
    let priorityRangeValue = {};
    if (scene.levelCode === 'SET_OF_BOOK') {
      priorityRangeValue = {
        setOfBooksId: scene.levelOrgId,
        setOfBooksName: scene.levelName
      };
      setOfBooksId = scene.levelOrgId;
    }
    if (scene.levelCode === 'COMPANY') {
      priorityRangeValue = {
        id: scene.levelOrgId,
        companyOID: scene.companyOID,
        name: scene.levelName
      };
    }
    this.setState({priorityValue, priorityRangeValue, setOfBooksId}, this.refreshCityOptions);
  };

  initPriorityValue = () => {
    const { record } = this.props;
    let setOfBooksId = "";
    let companyOID = "";
    if (record.levelCode === 'COMPANY' && record.travelRuleCompanyList) {
      companyOID = record.travelRuleCompanyList[0].companyOID;
    }
    let priorityValue = {
      levelCode: record.levelCode,
      levelOrgId: record.levelOrgId,
      levelOrgName: record.levelName
    };
    if (record.levelCode === "SET_OF_BOOK" && !record.isPublic) {
      //账套级，启用公司，且是部分公司
      let companyList = [];
      record.travelRuleCompanyList && record.travelRuleCompanyList.map(company => {
        companyList.push({name: company.companyName, id: company.companyId});
      });
      priorityValue.distribution = {companies: companyList};
    }
    let priorityRangeValue = {};
    if (record.levelCode === 'SET_OF_BOOK') {
      priorityRangeValue = {
        setOfBooksId: record.levelOrgId,
        setOfBooksName: record.levelName
      };
      setOfBooksId = record.levelOrgId;
    }
    if (record.levelCode === 'COMPANY') {
      priorityRangeValue = {
        id: record.levelOrgId,
        companyOID: companyOID,
        name: record.levelName
      };
    }
    this.setState({priorityValue, priorityRangeValue, setOfBooksId}, this.refreshCityOptions);
  };

  //新建差标处理所属组织默认值，用餐的除开
  initDefaultPriority = () => {
    const { permissionTop, hasProcessDefaultPriority } = this.state;
    const { record, sceneId } = this.props;
    if (hasProcessDefaultPriority || record || sceneId) {
      //只处理一次默认值，新建差标的时候处理，用餐的不处理
      return;
    }

    BaseService.dealDefaultPriority(permissionTop, 'id').then(res => {
      this.setState(res, () => {
        this.clearDependency();
        this.refreshCityOptions();
      });
    }).catch(error => {
      message.error(messages('common.error')/*哦呼，服务器出了点问题，请联系管理员或稍后再试:(*/);
    }).finally(() => {
      this.setState({hasProcessDefaultPriority: true});
    });
  };

  initUserScope = () => {
    const { record } = this.props;
    let userScopeValue = {
      range: 'ALL',
      value: []
    };
    let travelRuleRelations = record.travelRuleRelations;
    //1001 表明人员组是通用的，1002说明是部分人员组，其他类型的type和人员组差标配置无关
    //travelRuleRelations[0].type 不是1001 就是1002 没有其他可能
    if (travelRuleRelations && travelRuleRelations.length && travelRuleRelations[0].type !== 1001) {
      userScopeValue.range = "PERSON_GROUP";
      let userGroupList = [];
      travelRuleRelations.map(relation => {
        if (relation.type === 1002) {
          userGroupList.push({name: relation.relationName, userGroupOID: relation.relationOID});
        }
      });
      userScopeValue.value = userGroupList;
    }
    this.setState({userScopeValue});
  };

  initFormScope = () => {
    const { record } = this.props;
    let formScopeValue = {
      range: 'ALL',
      value: []
    };
    if (record.customFormDTOs && record.customFormDTOs.length) {
      formScopeValue = {
        range: 'PARTIAL',
        value: record.customFormDTOs
      }
    }
    this.setState({formScopeValue});
  };

  //初始化页面权限
  initPriority = (currentMenuPermission) => {
    let policyDTO = currentMenuPermission.currentMenuPermission && currentMenuPermission.currentMenuPermission.authPolicyCompDTO;
    if (policyDTO && policyDTO.setOfBooksIds && policyDTO.setOfBooksIds.length) {
      this.setState({permissionTop: 'SET_OF_BOOK'}, this.initDefaultPriority);
    } else {
      this.setState({permissionTop: 'COMPANY'}, this.initDefaultPriority);
    }
  };

  //初始化机票、火车舱等，座席
  initClassOptions = () => {
    const { travelType } = this.props;
    travelPolicyService.getTicketClass(travelType).then(resp => {
      if (resp.status === 200) {
        resp.data.unshift({
          code: messages('request-1.key769')/*所有*/,
          name: messages('request-1.key769')/*所有*/
        });
        this.setState({classOptions: resp.data});
      }
    })
  };

  //刷新城市级别
  refreshCityOptions = () => {
    const { priorityValue } = this.state;
    let cities = [
      {levelName: messages('request-1.key735')/*通用*/, levelOID: '000000000'},
      {levelName: messages('request-1.key512')/*其他*/, levelOID: '111111111'}
    ];
    if (priorityValue && priorityValue.levelOrgId) {
      let params = {
        levelCode: priorityValue.levelCode,
        levelOrgId: priorityValue.levelOrgId
      };
      policyService.getCityLevels(params).then(resp => {
        resp.data && resp.data.length && resp.data.map(city => {
          if (!city.deleted) {
            cities.push(city);
          }
        });
        this.setState({cityOptions: cities});
      });
    } else {
      this.setState({cityOptions: cities});
    }
  };

  handleSave = (e) => {
    e.preventDefault();
    this.props.form.validateFieldsAndScroll((err, values) => {
      if (!err && this.validateData(values)) {
        let params = this.processValue(values);
        this.setState({loading: true});
        let serviceName = params.id ? 'saveRule' : 'createRule';
        policyService[serviceName](params).then(resp => {
          this.setState({loading: false});
          message.success(messages('common.save.success',{arg1: params.comment})/*{arg1} 保存成功*/);
          this.props.close(true);
        }).catch(err => {
          this.setState({loading: false});
          errorMessage(err.response);
        })
      }
    });
  };

  validateData = (values) => {
    const { priorityValue, userScopeValue, formScopeValue } = this.state;
    if (!priorityValue.levelOrgId) {
      message.error(messages('request-1.key723')/*请选择所属组织*/);
      return false;
    }
    if (priorityValue.levelCode === 'SET_OF_BOOK' && priorityValue.distribution && !priorityValue.distribution.companies.length) {
      message.error(messages('request-1.key770')/*请选择启用公司*/);
      return false;
    }
    if (!userScopeValue.range || (userScopeValue.range === 'PERSON_GROUP' && !userScopeValue.value.length)) {
      message.error(messages('request-1.key771')/*请选择适用人员*/);
      return false;
    }
    if (formScopeValue && formScopeValue.range === 'PARTIAL' && !formScopeValue.value.length) {
      message.error(messages('request-1.key762')/*请选择适用表单*/);
      return false;
    }
    if (!values.comment){
      message.error(messages('request-1.key772')/*请输入名称*/);
      return false;
    }
    return true;
  };

  processValue = (values) => {
    const { priorityValue, priorityRangeValue, userScopeValue, valueRuleList, formScopeValue } = this.state;
    const { travelType, sceneId, record } = this.props;
    let params = {
      travelType,
      id: record ? record.id : undefined,
      comment: values.comment,
      status: values.status ? 1001 : 1002,
      levelCode: priorityValue.levelCode,
      levelOrgId: priorityValue.levelOrgId,
      customFormDTOs: formScopeValue.value
    };
    if (priorityValue.levelCode === 'SET_OF_BOOK') {
      if (priorityValue.distribution && priorityValue.distribution.companies && priorityValue.distribution.companies.length) {
        params.isPublic = false;
        params.travelRuleCompanyList = [];
        priorityValue.distribution.companies.map(company => {
          params.travelRuleCompanyList.push({companyId: company.id});
        });
      } else {
        params.isPublic = true;
      }
    } else {
      params.isPublic = false;
      //公司级travelRuleCompanyList要置空，查询的时候后台会返回
      params.travelRuleCompanyList = [];
    }
    params.travelRuleConditions = [];
    if (typeof values.flightDiscount === 'number') {
      if (values.flightDiscount > 10) {
        values.flightDiscount = 10;
      }
      if (values.flightDiscount < 0.1) {
        values.flightDiscount = 0.1;
      }
    }
    switch(travelType) {
      case 1001: //机票
        params.travelRuleConditions = [
          {
            name: 'flightSeatClass',
            code: 1001,
            value: values.class
          },
          {
            name: 'flightDiscount',
            code: 1002,
            value: values.flightDiscount
          },
          {
            name: 'flightScope',
            code: 1008,
            value: values.flightScope
          }
        ];
        break;
      case 1002: //火车
        params.travelRuleConditions = [
          {
            name: 'trainSeatClass',
            code: 1003,
            value: values.class
          }
        ];
        break;
      case 1003: //酒店
      case 1008: //用车
      case 1010: //用餐
        params.travelRuleConditions = [
          {
            name: 'cityLevel',
            code: 1006,
            value: values.cityLevel
          },
          {
            name: 'currency',
            code: 1005,
            value: 'CNY'
          },
          {
            name: 'amount',
            code: 1004,
            value: values.amount
          }
        ];
        if (travelType === 1003) {
          params.travelRuleConditions.push({
            name: 'hotelUniformBooking',
            code: 1007,
            value: values.isUniform
          });
        }
        if (travelType === 1008) {
          params.visibleFormScope = (params.customFormDTOs && params.customFormDTOs.length) ? 2 : 1; //适用表单范围，1全部 2部分
        }
        if (travelType === 1010) {
          params.diningSceneId = sceneId;
        }
        break;
    }
    params.travelRuleRelations = [];
    if (userScopeValue.range === 'PERSON_GROUP') {
      userScopeValue.value.map(userGroup => {
        params.travelRuleRelations.push({
          type: 1002,
          relationOID: userGroup.userGroupOID
        });
      });
    } else {
      params.travelRuleRelations = [{type: 1001, relationOID: null}];
    }
    params.customEnumerationDTOs = [];
    valueRuleList.map(oneRule => {
      if (oneRule.value) {
        let oneRuleData = {};
        oneRuleData.customEnumerationOID = oneRule.value;
        oneRuleData.values = [];
        oneRule.valueItem.map(valueId => {
          oneRuleData.values.push({id: valueId});
        });
        params.customEnumerationDTOs.push(oneRuleData);
      }
    });
    return params;
  };

  handleChangePriority = (value) => {
    const { priorityValue: oldPriorityValue } = this.state;
    if (value && value.levelCode === 'COMPANY' && value.levelOrgId !== oldPriorityValue.levelOrgId) {
      //所属组织为公司，切换公司时清空依赖数据
      this.clearDependency();
    }
    this.setState({priorityValue: value || {}}, this.refreshCityOptions);
  };

  handleChangePriorityRange = (value) => {
    const { setOfBooksId: oldSetOfBooksId } = this.state;
    if (!value) {
      //如果为空，清空依赖数据
      this.clearDependency();
      this.setState({setOfBooksId: ''});
    } else {
      let newSetOfBooksId = value.setOfBooksId;
      newSetOfBooksId !== oldSetOfBooksId && this.clearDependency();
      this.setState({setOfBooksId: newSetOfBooksId});
    }
    this.setState({priorityRangeValue: value});
  };

  //所属组织切换了账套或者切换了公司，清除依赖账套，公司查询的配置数据
  clearDependency = () => {
    const { form, travelType } = this.props;
    let { userScopeValue, formScopeValue } = this.state;
    if (travelType === 1003 || travelType === 1010 || travelType === 1008) {
      form.setFieldsValue({
        'cityLevel': '000000000'
      });
    }
    userScopeValue.value = [];
    formScopeValue.value = [];
    this.setState({customEnumerationDTOs: [], isShowValueRule: false, valueRuleList: [], userScopeValue, formScopeValue}, () => {
      this.setState({isShowValueRule: true});
    });
  };

  handleStatusChange = (value, key) => {
    this.setState({
      [key]: value
    });
  };

  getInitialValue = (fieldKey) => {
    const { record, form, travelType } = this.props;
    let travelRuleConditions = record.travelRuleConditions || [];
    let nameKey = '';
    let value = '';
    switch (fieldKey) {
      case 'flightScope':
        nameKey = 'flightScope';
        break;
      case 'cityLevel':
        nameKey = 'cityLevel';
        break;
      case 'class':
        nameKey = travelType === 1001 ? 'flightSeatClass' : 'trainSeatClass';
        break;
      case 'flightDiscount':
        nameKey = 'flightDiscount';
        break;
      case 'amount':
        nameKey = 'amount';
        break;
      case 'isUniform':
        nameKey = 'hotelUniformBooking';
        break;

    }
    travelRuleConditions.map(condition => {
      if (condition.name === nameKey) {
        if (nameKey === 'hotelUniformBooking') {
          value = condition.value === "true";
        } else {
          value = condition.value;
        }
      }
    });
    return value;
  };

  onCancel = () => {
    this.props.close();
  };

  render() {
    const { getFieldDecorator, getFieldValue } = this.props.form;
    const { disabled, loading, permissionTop, priorityValue, userScopeValue, classOptions,
      cityOptions, setOfBooksId, customEnumerationDTOs, isShowValueRule, priorityRangeValue, formScopeValue,
      hasProcessDefaultPriority
    } = this.state;
    const { travelType, record, sceneId } = this.props;
    const formItemLayout = {
      labelCol: {span: 6},
      wrapperCol: {span: 15}
    };
    const formItemLayoutBig = {
      labelCol: {span: 6},
      wrapperCol: {span: 17}
    };
    return (
      <div className="new-form travel-standard-detail">
        <Form onSubmit={this.handleSave}>
          <FormItem {...formItemLayout} label={messages('common.column.status')/*状态*/}>
            {getFieldDecorator('status', {
              initialValue: record ? record.status === 1001 : true,
              valuePropName: 'checked'
            })(
              <Switch disabled={disabled} />
            )}
          </FormItem>
          {/* 复制编辑的时候有record，没有id */}
          {(hasProcessDefaultPriority || record || sceneId) && (
            <Priority
              top={!(record || sceneId) ? permissionTop : 'SET_OF_BOOK'}
              onChange={this.handleChangePriority}
              formItemLayout={formItemLayout}
              onChangeRange={this.handleChangePriorityRange}
              companyProps={{
                single: !priorityValue.levelOrgId || (priorityValue.levelOrgId && priorityValue.levelCode === 'COMPANY'),
                disabled: (record || sceneId) && priorityValue.levelCode === 'COMPANY'
              }}
              defaultValue={priorityValue}
              disabledTop={!!record || !!sceneId}
              disabled={disabled || ((record || sceneId) && priorityValue.levelCode === 'COMPANY')}
            />
          )}
          <Permission
            onChange={value => this.handleStatusChange(value, 'userScopeValue')}
            formItemLayout={formItemLayout}
            hidden={['DEPARTMENT']}
            parser={value => ({range: value.range, value: value.value || []})}
            value={userScopeValue}
            componentProps={{
              'PERSON_GROUP': {
                valueKey: 'userGroupOID',
                listExtraParams:{
                  levelCode: priorityValue.levelCode,
                  levelOrgId: priorityValue.levelOrgId
                }
              }
            }}
            disabled={disabled || !priorityValue.levelOrgId}
          />
          {travelType === 1008 && (
            <FormItem {...formItemLayout} label={messages('request-1.key746')/*适用表单*/}>
              <div className='normal-width'>
                <AllocationForm
                  componentProps={{
                    'PARTIAL': {
                      listExtraParams: {
                        setOfBooksId,
                        companyOID: priorityValue.levelCode === 'SET_OF_BOOK' ? undefined : priorityRangeValue && priorityRangeValue.companyOID,
                        formTypeList: [2001],
                        withSetOfBooks: false
                      }
                    }
                  }}
                  parser={value => ({range: value.range, value: value.value || []})}
                  value={formScopeValue}
                  onChange={value => this.handleStatusChange(value, 'formScopeValue')}
                  disabled={disabled || !priorityValue.levelOrgId}
              />
              </div>
            </FormItem>
          )}
          <div className="sub-title">{messages('request-1.key773')/*标准设置*/}</div>
          <FormItem {...formItemLayout} label={messages('request-1.key326')/*名称*/}>
            {getFieldDecorator('comment', {
              rules: [{
                required: true,
                message: messages('common.please.input')/*请输入*/
              }],
              initialValue: record ? record.comment : ''
            })(
              <Input placeholder={messages('common.please.input')/*请输入*/} maxLength="10" disabled={disabled}/>
            )}
          </FormItem>
          {travelType === 1001 && (
            <FormItem {...formItemLayout} label={messages('request-1.key774')/*范围*/}>
              {getFieldDecorator('flightScope', {
                rules: [{
                  required: true,
                  message: messages('common.select')/*请选择*/
                }],
                initialValue: record ? this.getInitialValue('flightScope') : '1001'
              })(
                <RadioGroup disabled={disabled}>
                  <Radio value={'1001'}>{messages('request-1.key735')/*通用*/}</Radio>
                  <Radio style={{marginLeft: 50}} value={'1002'}>{messages('request-1.key437')/*国内*/}</Radio>
                  <Radio style={{marginLeft: 50}} value={'1003'}>{messages('request-1.key438')/*国际*/}</Radio>
                </RadioGroup>
              )}
            </FormItem>
          )}
          {(travelType === 1003 || travelType === 1010 || travelType === 1008) && (
            <FormItem {...formItemLayout} label={messages('request-1.key775')/*城市级别*/}>
              {getFieldDecorator('cityLevel', {
                rules: [{
                  required: true,
                  message: messages('common.select')/*请选择*/
                }],
                initialValue: record ? this.getInitialValue('cityLevel') : '000000000'
              })(
                <Select disabled={disabled || !priorityValue.levelOrgId}>
                  {cityOptions.map(item => {
                    return <Option value={item.levelOID} key={item.levelOID}>{item.levelName}</Option>
                  })}
                </Select>
              )}
            </FormItem>
          )}
          {travelType !== 1010 && travelType !== 1008 && (
            <FormItem {...formItemLayoutBig} label={messages('request-1.key776')/*条件*/}>
              {isShowValueRule && (
                <ValueRule
                  data={{
                    customEnumerationDTOs: record ? customEnumerationDTOs : []
                  }}
                  onChange={value => this.handleStatusChange(value, 'valueRuleList')}
                  disabled={disabled || !priorityValue.levelOrgId}
                  levelCode={priorityValue.levelCode}
                />
              )}
            </FormItem>
          )}
          {(travelType === 1001 || travelType === 1002) && (
            <FormItem {...formItemLayout} label={travelType === 1001 ? messages('request-1.key777')/*生效舱等*/ : messages('request-1.key778')/*生效座席*/}>
              {getFieldDecorator('class', {
                rules: [{
                  required: true,
                  message: messages('common.select')/*请选择*/
                }],
                initialValue: record ? this.getInitialValue('class') : (classOptions.length !== 0 ? (travelType === 1001 ? classOptions[1].name : undefined) : undefined)
              })(
                <Select disabled={disabled}>
                  {classOptions.map(item => {
                    return <Option value={travelType === 1001 ? item.name : item.code} key={item.name}>{item.name}</Option>
                  })}
                </Select>
              )}
            </FormItem>
          )}
          {travelType === 1001 && (
            <FormItem {...formItemLayout} label={messages('request-1.key779')/*生效折扣*/}>
              {getFieldDecorator('flightDiscount', {
                initialValue: record ? this.getInitialValue('flightDiscount') : undefined
              })(
                <InputNumber
                  style={{width: '33%'}}
                  placeholder={messages('common.please.input')/*请输入*/}
                  max={10}
                  min={0.1}
                  precision={1}
                  step={0.1}
                  disabled={disabled}
                />
              )}
              <div style={{color: '#989898'}}>{messages('request-1.key780')/*折扣限制仅限国内机票，请输入0.1~10.0之间的数字，为空代表不限制票价*/}</div>
            </FormItem>
          )}
          {(travelType === 1003 || travelType === 1010 || travelType === 1008) && (
            <FormItem {...formItemLayout} label={messages('request-1.key781')/*生效标准*/}>
              {getFieldDecorator('amount', {
                rules: [{
                  required: travelType === 1010, //用车，酒店金额不必填，用餐的金额还是必填的
                  message: messages('common.please.input')/*请输入*/
                }],
                initialValue: record ? this.getInitialValue('amount') : null
              })(
                <Amount disabled={disabled} customClass='normal-width' />
              )}
            </FormItem>
          )}
          {travelType === 1003 && (
            <FormItem {...formItemLayout} label={messages('request-1.key782')/*是否合住*/}>
              {getFieldDecorator('isUniform', {
                initialValue: record ? this.getInitialValue('isUniform') : false
              })(
                <RadioGroup disabled={disabled}>
                  <Radio value={true}>{messages('request-1.key783')/*合住*/}</Radio>
                  <Radio style={{marginLeft: 50}} value={false}>{messages('request-1.key784')/*不合住*/}</Radio>
                </RadioGroup>
              )}
              <div style={{color: '#989898'}}>{messages('request-1.key785')/*请确保所有员工性别已维护*/}</div>
            </FormItem>
          )}
          <div className="slide-footer">
            {!disabled && (
              <Button type="primary" htmlType="submit" loading={loading}>{messages('common.ok')/*确定*/}</Button>
            )}
            <Button onClick={this.onCancel}>{messages('common.cancel')/*取消*/}</Button>
          </div>
        </Form>
      </div>
    )
  }
}

function mapStateToProps(state) {
  return {
    currentMenuPermission: state.main.currentMenuPermission
  }
}
const WrappedNewRule = Form.create()(NewRule);

export default connect(mapStateToProps)(WrappedNewRule)
